package com.yips.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yips.common.constant.UserConstants;
import com.yips.domain.entity.SysUser;
import com.yips.service.SysUserService;
import com.yips.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Gralt of Rivia
 * @desc 针对表【sys_user】的数据库操作Service实现
 * 2022-05-08 11:15:38
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
        implements SysUserService {

    @Autowired
    private SysUserMapper userMapper;

    @Override
    public SysUser selectUserByUserName(String username) {

        return userMapper.selectUserByUserName(username);
    }

    @Override
    public String checkUserNameUnique(String username) {
        int count = userMapper.checkUserNameUnique(username);
        if (count > 0) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public boolean registerUser(SysUser sysUser) {
        return userMapper.insertSysUser(sysUser) == 1;
    }
}




